﻿using System;

namespace octalforty.Syndication.Core.Rss
{
    /// <summary>
    /// Represents an RSS feed.
    /// </summary>
    public sealed class RssFeed : ISyndicationFeed
    {
        #region Private Member Variables
        private RssChannel channel = new RssChannel();
        #endregion

        #region Public Properties
        /// <summary>
        /// Gets or sets a reference to the <see cref="RssChannel"/> which represents
        /// a RSS channel of this feed.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// When <paramref name="value"/> is a <c>null</c> reference.
        /// </exception>
        public RssChannel Channel
        {
            get { return channel; }
            set
            {
                if(value == null)
                    throw new ArgumentNullException("value");

                channel = value;
            }
        }
        #endregion

        /// <summary>
        /// Initializes a new instance of <see cref="RssFeed"/> class.
        /// </summary>
        public RssFeed()
        {
        }

        #region ISyndicationFeed Members
        /// <summary>
        /// Gets or sets a <see cref="String"/> which contains a human-readable
        /// title for the <see cref="ISyndicationFeed"/>.
        /// </summary>
        /// <example>GoUpstate.com News Headlines</example>
        public String Title
        {
            get { return Channel.Title; }
            set { Channel.Title = value; }
        }

        /// <summary>
        /// Gets or sets a <see cref="String"/> which contains the URL
        /// of the website which corresponds to the <see cref="ISyndicationFeed"/>.
        /// </summary>
        public String Link
        {
            get { return Channel.Link; }
            set { Channel.Link = value; }
        }

        /// <summary>
        /// Gets or sets a <see cref="String"/> which contains a phrase or a sentence 
        /// describing the <see cref="ISyndicationFeed"/>.
        /// </summary>
        /// <example>
        /// The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.
        /// </example>
        public String Description
        {
            get { return Channel.Description; }
            set { Channel.Description = value; }
        }

        /// <summary>
        /// Gets or sets a <see cref="String"/> which contains copyright notice 
        /// for content in the <see cref="ISyndicationFeed"/>.
        /// </summary>
        /// <example>Copyright 2002, Spartanburg Herald-Journal</example>
        public String Copyright
        {
            get { return Channel.Copyright; }
            set { Channel.Copyright = value; }
        }

        /// <summary>
        /// Gets or sets the <see cref="IPerson"/> which represents a person responsible 
        /// for editorial content of the <see cref="ISyndicationFeed"/>.
        /// </summary>
        /// <example>George Matesky &lt;geo@herald.com&gt;</example>
        public IPerson ManagingEditor
        {
            get { return Channel.ManagingEditor; }
            set { Channel.ManagingEditor = value; }
        }

        /// <summary>
        /// Gets or sets the <see cref="IPerson"/> which represents a person responsible for 
        /// technical issues relating to the feed.
        /// </summary>
        /// <example>Betty Guernsey &lt;betty@herald.com&gt;</example>
        public IPerson WebMaster
        {
            get { return Channel.WebMaster; }
            set { Channel.WebMaster = value; }
        }

        /// <summary>
        /// Gets or sets the <see cref="IPerson"/> which represents a person
        /// who is the author of the <see cref="ISyndicationFeed"/>.
        /// </summary>
        public IPerson Author
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        /// <summary>
        /// Gets or sets the <see cref="IPerson"/> which represents a person
        /// who is the contributor to the content of the <see cref="ISyndicationFeed"/>.
        /// </summary>
        public IPerson Contributor
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        /// <summary>
        /// Gets or sets the <see cref="DateTime"/> which contains the date and time
        /// of initial creation or first availability of the <see cref="ISyndicationFeed"/>.
        /// </summary>
        public DateTime? PublishedOn
        {
            get { return Channel.PublishedOn; }
            set { Channel.PublishedOn = value; }
        }

        /// <summary>
        /// Gets or sets the <see cref="DateTime"/> which indicates the date and time
        /// indicating the most recent instant in time when the <see cref="ISyndicationFeed"/> was modified 
        /// in a way the publisher considers significant.
        /// </summary>
        public DateTime? UpdatedOn
        {
            get { return Channel.UpdatedOn; }
            set { Channel.UpdatedOn = value; }
        }

        /// <summary>
        /// Gets or sets a <see cref="String"/> which contains a permanent, universally unique
        /// identifier for the <see cref="ISyndicationFeed"/>.
        /// </summary>
        public String UniqueIdentifier
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        /// <summary>
        /// Gets a reference to the <see cref="SyndicationFeedItemCollection"/> which contains
        /// all <see cref="ISyndicationFeedItem"/> for the current <see cref="ISyndicationFeed"/>.
        /// </summary>
        public SyndicationFeedItemCollection Items
        {
            get { return new SyndicationFeedItemCollection(Channel.Items); }
        }
        #endregion
    }
}
